package org.chw.netty;

import org.chw.netty.server.EchoServer;
import org.chw.netty.server.SocketServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Hello world!
 */
public class NettyServerApp {
  private static final Logger LOGGER = LoggerFactory.getLogger(NettyServerApp.class);

  public static void main(String[] args) throws InterruptedException {
    new NettyServerApp().startSocketServer();
  }

  private void startSocketServer() {
    new SocketServer(9000).start();
  }

  private void startEchoServer(String[] args) {
    if (args.length != 1) {
      LOGGER.error("Usage:{}<port>", EchoServer.class.getSimpleName());
      return;
    }
    int port = Integer.parseInt(args[0]); // 设置端口
    try {
      new EchoServer(port).start(); // 启动服务器
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
}
